/*************************************************************
 * File: HttpHelper.java
 * Copyright (c) 2012
 * Author: Huang Shaobin
 * Email: Shaobin.Software@gmail.com Shaobin_Software@163.com 
 * Date: Feb 10, 2013
 * Description: 
 ************************************************************/

package snow.core.toolkit;

import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpMethod;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 * HTTP处理相关的工具类
 * 
 * @author Shaobin.Software@gmail.com Shaobin_Software@163.com
 * @version 1.0
 */
public class HttpHelper {
	
	private static final Log log = LogFactory.getLog(HttpHelper.class);

	public static int execute(final HttpMethod method) {
		HttpClient client = new HttpClient();
		if (method != null) {
			try {
				return client.executeMethod(method);
			} catch (Exception e) {
				log.error(e.getMessage(), e);
			} finally {
				method.releaseConnection();
			}
		}
		return -1;
	}

}
